package org.lq.shopping.util;

import java.util.List;

/**
 * 分页工具类
 * @author 无语
 *
 * @时间 2018年9月12日
 * 20180912_page
 */
public class Page<T> {

	
	private List<T> list;//数据源
	private int pageIndex;//当前页数
	private int totalPage;//总页数
	private int pageSize;//每页显示行数
	private int pageCount;//总行数
	
	/**
	 * 返回总页数
	 * @return
	 */
	public int getTotalPage() {
		this.totalPage = pageCount%pageSize ==0 ? pageCount/pageSize : pageCount/pageSize+1;
		return totalPage;
	}
	/**
	 * 赋值当前页数
	 * @param pageIndex
	 */
	public void setPageIndex(int pageIndex) {
		if(pageIndex<=1) {
			this.pageIndex = 1;
		}else if(pageIndex > getTotalPage()) {
			this.pageIndex = totalPage;
		}else {
			this.pageIndex = pageIndex;
		}
	}
	/**
	 * 获取当前页数
	 * @return
	 */
	public int getPageIndex() {
		return pageIndex;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageCount() {
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
		getTotalPage();
	}
	
	
}









